package vn.cent.game.cardtype.client;

import vn.cent.game.cardtype.beans.GameBean;
import vn.cent.game.cardtype.main.CardTypeGameExtension;
import vn.cent.game.cardtype.main.RoomController;
import vn.cent.game.cardtype.utils.GameKind;

import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.extensions.BaseClientRequestHandler;

/*
 * IClientHandler will make a bridge between BaseClientRequestHandler and our handler class
 * We use this class to define our controller to avoid duplicate code. 
 * Our handler class should extends from IClientHandler.
 * Please check @RequestNextStep class for examples.
 */
public abstract class IClientHandler extends BaseClientRequestHandler {
	protected CardTypeGameExtension extension;
	protected GameKind gameKind;
	protected User sender;
	protected RoomController roomController;

	@Override
	public void handleClientRequest(User user, ISFSObject data) {
		trace("[IClientHandler] Start build our handler");
		byte tempGameKind = data.getByte("GameKind");
		sender = user;

		SetupVariables();

		/*
		 * Index converter
		 * 1 = BC
		 * 2 = CA
		 * Add your game index and handle function
		 */

		switch (tempGameKind) {
		case 1:
			gameKind = GameKind.BC;
			break;
		case 2:
			gameKind = GameKind.CA;
			break;
		default:
			break;
		}
		
		MakeHandler(data);
	}

	protected void SetupVariables()
	{
		extension = (CardTypeGameExtension) getParentExtension();
		roomController = new RoomController(this.getApi(), extension, sender);
	}
	
	public void MakeHandler(ISFSObject data) {
		
	}
	
	
	
}
